package com.itheima.arraylist;

import java.util.ArrayList;

public class ArrayListTest {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        list.add(1, "赵六");
        System.out.println(list);
        //删除
        //list.remove("王五");
        //list.remove(2);
        //System.out.println(list);
        //修改
        /*list.set(2,"思思");
        System.out.println(list);
        //查询
        String s = list.get(3);
        System.out.println("s = " + s);*/
        int size = list.size();
        System.out.println("size = " + size);

        list.add("ttt");
        list.add("ttt");
        list.add("ttt");
        System.out.println(list);
        for (int i = list.size()-1; i >=0; i--) {
            if("ttt".equals(list.get(i))){
                list.remove(i);
            }
        }
        System.out.println(list);
    }
}
